import { version } from "#package";

export const HOME_PAGE_ROUTE_PATH = "/home";
export const LOGIN_PAGE_ROUTE_PATH = "/login";

export const appVersion = version;

export const isPrd = import.meta.env.PROD;

const appConfigKey = import.meta.env.VITE_GLOBAL_CONFIG_KEY;

export interface ZGlobalEnv {
  baseApiUrl: string;
  appTitle: string;
  cryptoSecret: string;
}

export function getGlobalEnv(): ZGlobalEnv {
  if (isPrd) {
    return {
      baseApiUrl: window[appConfigKey].VITE_BASE_API_URL,
      appTitle: window[appConfigKey].VITE_APP_TITLE,
      cryptoSecret: window[appConfigKey].VITE_CRYPTO_SECRET,
    };
  }

  return {
    baseApiUrl: import.meta.env.VITE_BASE_API_URL,
    appTitle: import.meta.env.VITE_APP_TITLE,
    cryptoSecret: import.meta.env.VITE_CRYPTO_SECRET,
  };
}

export function getFullImgPath(imgPath: string) {
  const { baseApiUrl } = getGlobalEnv();
  return imgPath.replace("@", baseApiUrl + "/");
}
